import java.util.HashSet;
import java.util.Set;

/**
 * @program: LeetCode
 * @description: LeetCode :
 * @author: WXY
 * @create: 2022-12-25 16:02
 * @Version 1.0
 **/

public class one1_containsDuplicate {
    public static boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int c : nums) {
            if (!set.add(c)) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 1};
        boolean b = containsDuplicate(arr);
        System.out.println(b);
    }
}
